<?php
use Homework5\Maze as Maze;
use Homework5\UnionSet as UnionSet;
set_time_limit(0);
/* Autoload classes */
function __autoload($className) {
	$parts = explode('\\', $className);
	include end($parts) . '.php';
}

$size = 6;
$nrElements = $size * $size;
$unionSet = new UnionSet(6);

while (!$unionSet->find(0, $nrElements-1)) {
	list($a, $b) = array(mt_rand(0, $nrElements-1), mt_rand(0, $nrElements-1));
	$unionSet->unionFind($a, $b);
}
die('x');
$nrElements = 10000;
$trials = 200;

$file = fopen('trials.txt', 'w+');

for ($i = 0; $i < $trials; $i++) {
	$unionSet = new UnionSet($nrElements);
	while (!$unionSet->isUnified()) {
		list($a, $b) = array(mt_rand(0, $nrElements-1), mt_rand(0, $nrElements-1));
		$unionSet->unionFind($a, $b);
	}
	
	fwrite($file, ($i+1) . "\t" . $unionSet->getSearchCount() .
		"\t" . $unionSet->getUnionCount() . "\t" . $unionSet->getParentSearchCount() .  PHP_EOL);
}

fclose($file);

